package com.ysw.wisdomcampus.kt

import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.View
import android.view.ViewTreeObserver
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.Navigation
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.GlideDrawable
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import kotlinx.coroutines.*
import java.lang.Exception

/**
 * 高阶函数
 */

inline fun glide(
    context: Context,
    path: String = "",
    resId: Int = 0,
    view: ImageView
) {
    Glide.with(context).load(if (path != "" && resId == 0) path else resId)
        .into(view)
}

inline fun start(
    context: Context,
    noinline block: () -> Intent
) {
    context.startActivity(block.invoke())
}

 fun Fragment.navigate(
     view: View,
     actionId: Int
 ) {
    Navigation.findNavController(view).navigate(actionId)
}

